import { useDispatch, useSelector } from "react-redux";
import store, { RootState } from "@/store";

// Creates a 'pre-typed' version of useDispatch where the type of the dispatch function is predefined.
// 创建 useDispatch 的预定义类型版本，其中 dispatch 函数的类型是预定义的
// This allows you to set the dispatch type once,eliminating the need to specify it with every useDispatch call
// 这允许您设置一次dispatch类型，无需在每次useDispatch时为dispatch指定type美型。
// export const useAppDispatch = () => useDispatch<typeof store.dispatch>()
export const useAppDispatch = useDispatch.withTypes<typeof store.dispatch>();
export const useAppSelector = useSelector.withTypes<RootState>()
